package com.share.beta.init;

import com.alibaba.fastjson.JSON;
import com.share.beta.feign.outapi.OutApiFeign;
import com.share.beta.feign.outapi.dto.dto.UserRsAReq;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Data
@Slf4j
@Component
public class BootInit {
    @Autowired
    private OutApiFeign outApiFeign;

    @PostConstruct
    @Scheduled(cron = "0 0/5 * * * ?")
    public void initHttp() {
        log.info("---正在初始化或者刷新-dictionaryService---");
        Object result = init();
        log.info("dictionaryService配置={}", JSON.toJSONString(result));
    }

    @PostConstruct
    public void testFeign() {
        log.info("---正在测试feign---");
        UserRsAReq req = new UserRsAReq();
        req.setName("syq821781113");
        outApiFeign.hpGet("req", "dd");
    }

    private Object init() {
        return "你好";
    }
}
